package com.hpxx.ylzswl.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpxx.ylzswl.R;
import com.hpxx.ylzswl.bean.ChooseBean;
import com.hpxx.ylzswl.utils.ViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/11/9.
 */

public class ChooseAdapter extends BaseAdapter{

    private Context context;
    private List<ChooseBean> list;

    public ChooseAdapter(Context context, List<ChooseBean> list){
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ChooseBean getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
//        ChooseBean bean = getItem(position);
        if(view == null){
            view = View.inflate(context, R.layout.item_choose,null);
        }

        TextView tv_name = ViewHolder.get(view,R.id.tv_name);
        tv_name.setText(list.get(position).itemName);
        TextView tv_fl = ViewHolder.get(view,R.id.tv_fl);
        tv_fl.setText("所属分类："+list.get(position).typeName);
        TextView tv_money = ViewHolder.get(view,R.id.tv_money);
        tv_money.setText("¥ "+list.get(position).itemPrice);
//        ImageView iv_add = ViewHolder.get(view,R.id.iv_add);

        return view;

    }

}
